<?php

class RegisterForm extends CFormModel
{
	public $email;
	public $password;
	public $password2;

	public function rules()
	{
		return array(
			array('email, password, password2', 'required'),
			array('email', 'email'),
			array('email', 'unique', 'className'=>'User'),
			array('password2', 'matchPasswords'),
		);
	}

	public function attributeLabels()
	{
		return array(
			'email'=>Yii::t('label','E-mail'),
			'password'=>Yii::t('label','New password'),
			'password2'=>Yii::t('label','Re-enter password'),
		);
	}

	public function matchPasswords($attribute, $params)
	{
		if ($this->password !== $this->password2)
			$this->addError($attribute,Yii::t('frontend','Passwords do not match.'));
	}
}
